package org.genew.squadra.xml.presentation;

import org.genew.squadra.xml.common.ValidationUtility;
import org.genew.squadra.xml.model.MyFileForm;
import org.genew.squadra.xml.model.MyMultipleFileForm;
import org.genew.squadra.xml.model.content.metadati.Metadata;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import org.springframework.stereotype.Component;
@Component
public class ExtensionValidator implements Validator {
	@Override
	public boolean supports(Class<?> klass) {
		// TODO Auto-generated method stub
		return MyMultipleFileForm.class.isAssignableFrom(klass);
	}

	@Override
	public void validate(Object target, Errors error) {
		MyMultipleFileForm myform = (MyMultipleFileForm) target;
		ValidationUtility.rejectIfNoExt(error, "errors.extension", myform.getCommonsMultipartFilesCSS(), "css", "commonsMultipartFilesCSS");
		ValidationUtility.rejectIfNoExt(error, "errors.extension", myform.getCommonsMultipartFilesIMG(), "jpg",  "commonsMultipartFilesIMG" );
	
		
		
		
		
	}

}
